<?php
/**
 * common repository file Created by PhpStorm.
 * User: yang
 * Date: 2020/06/23
 */

namespace Common\Repository;

use Common\Model\ForumComment;
use DB;

class ForumCommentRepository extends BaseRepository
{
    public function baseModel()
    {
        return new ForumComment();
    }

    /**
     * 回复榜
     */
    public function extendReplyList()
    {
        $select = ['id', 'user_id', DB::raw("count(1) as total")];
        return ForumComment::with('get_user')
            ->groupBy('user_id')
            ->orderBy('total', 'desc')
            ->limit(12)
            ->get($select)
            ->toArray();
    }

}